package com.cn.lp.domain;

import com.cn.lp.configuration.RabbitMqConfig;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by qirong on 2019/3/26.
 */
@Component
public class FirstSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送消息
     *
     * @param uuid
     * @param message 消息
     */
    public void send(String uuid, Object message) {
        //消息唯一id
        CorrelationData correlationId = new CorrelationData(uuid);
        rabbitTemplate.convertAndSend(
            RabbitMqConfig.EXCHANGE, RabbitMqConfig.ROUTINGKEY2,
            "test", correlationId
        );
    }

}
